package com.pearlsoft.webapp.sysmgr.cachemgr;

import java.util.Iterator;
import java.util.List;


import com.pearlsoft.webapp.core.annotation.QueryHandlerComponent;
import com.pearlsoft.webapp.core.dataset.DataSet;
import com.pearlsoft.webapp.core.dataset.Query;

import com.pearlsoft.webapp.core.web.basehandler.AbsBaseQueryHandler;
import com.pearlsoft.webapp.sysmgr.cache.CacheInfo;
import com.pearlsoft.webapp.sysmgr.cache.CacheService;

@QueryHandlerComponent(name = "CacheQueryHandler")
public class CacheQueryHandler  extends AbsBaseQueryHandler {
	@Override
	public void handler(Query query, DataSet ds) throws Exception {
		CacheService cacheService = this.getBean("cacheService", CacheService.class);
		List<CacheInfo> list = cacheService.getCaches();
		for(Iterator<CacheInfo> iter = list.iterator(); iter
				.hasNext();){
			CacheInfo cache = iter.next();
			ds.newRecord();
			ds.setValue("name",cache.getName());
			ds.setValue("count",cache.getCount());
			ds.setValue("cacheHits",cache.getCacheHits());
			ds.setValue("memSize",cache.getMemSize());
			ds.setValue("diskSize",cache.getDiskSize());
			ds.setValue("totalSize",cache.getTotalSize());
			ds.setValue("avgGetTime",cache.getAvgGetTime());
		}
		
	}

	@Override
	public void getEntity(Query query, DataSet ds) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void quickSearch(Query query, DataSet ds) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void advSearch(Query query, DataSet ds) throws Exception {
		// TODO Auto-generated method stub
		
	}
}
